package com.goods.business.converter;

import com.goods.common.model.business.Supplier;
import com.goods.common.vo.business.SupplierVO;
import org.springframework.beans.BeanUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

public class SupplierConverter {

    /**
     * 转vo
     */
    public static SupplierVO converterToSupplierVO(Supplier supplier){
        SupplierVO supplierVO = new SupplierVO();
        BeanUtils.copyProperties(supplier,supplierVO);
        return supplierVO;
    }

    /**
     * 转成supplierVOList
     */
    public static List<SupplierVO> converterToSupplierVOList(List<Supplier> supplierList){
        List<SupplierVO> supplierVOList = new ArrayList<>();
        if(!CollectionUtils.isEmpty(supplierList)){
            for (Supplier supplier : supplierList) {
                SupplierVO supplierVO = converterToSupplierVO(supplier);
                supplierVOList.add(supplierVO);
            }
        }
        return supplierVOList;
    }
}
